<!-- <script setup>
import { onHide, onShow, onLaunch, onPageNotFound } from '@dcloudio/uni-app'
import { provide } from 'vue'
import { useTokenStore } from '@/stores/token'
provide('baseUrl', 'http://fox_watch')
const tokenStore = useTokenStore()
onLaunch(() => {
  console.log('App Launch')
  uni.onPushMessage((res) => {
    console.log('收到推送消息：', res) //监听推送消息
  })
  let token = tokenStore.getToken()
  if (token == null || token == '') {
    uni.reLaunch({
      url: '/pages/login/index',
    })
  } else {
    uni.reLaunch({
      url: '/pages/home/index',
    })
  }
})
onShow(() => {
  console.log('App Show')
})
onHide(() => {
  console.log('App Hide')
})
onPageNotFound([
  function (res) {
    // 目前版本有Bug，需要使用一个数组函数，后续版本不需要定义为数组
    console.log('onPageNotFound:', res)
  },
])
</script> -->
<script>
// 只能在App.vue里监听应用的生命周期
export default {
  onLaunch: function (options) {
    console.log("App Launch");
    console.log("应用启动路径：", options.path);

    //     uni.share({
    // 	provider: "weixin",
    // 	scene: "WXSceneSession",
    // 	type: 1,
    // 	summary: "我正在使用HBuilderX开发uni-app，赶紧跟我一起来体验！",
    // 	success: function (res) {
    // 		console.log("success:" + JSON.stringify(res));
    // 	},
    // 	fail: function (err) {
    // 		console.log("fail:" + JSON.stringify(err));
    // 	}
    // });
    //这里的分享注意以后需要单独写页面放服务器上不然，点进去看不到内容的
    // uni.share({
    // 	provider: "weixin",
    // 	scene: "WXSceneSession",
    // 	type: 0,
    // 	href: "http://uniapp.dcloud.io/",
    // 	title: "uni-app分享",
    // 	summary: "我正在使用HBuilderX开发uni-app，赶紧跟我一起来体验！",
    // 	imageUrl: "https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/uni@2x.png",
    // 	success: function (res) {
    // 		console.log("success:" + JSON.stringify(res));
    // 	},
    // 	fail: function (err) {
    // 		console.log("fail:" + JSON.stringify(err));
    // 	}
    // });
  },
  onShow: function (options) {
    console.log("App Show");
    console.log("应用启动路径：", options.path);
  },
  onHide: function () {
    console.log("App Hide");
  },
  onPageNotFound: async function (a) {
    console.log(a);
    console.log("页面未找到");
    // h5跳转页面
    //#ifdef H5
    this.$router.push("/pages/404/index");
    //#endif
    uni.reLaunch({
      url: "/pages/404/index",
      success: function () {
        console.log("跳转成功");
      },
      fail: function (err) {
        console.log("跳转失败");
      },
      complete: function () {
        console.log("跳转完成");
      },
    });
  },
};
</script>

<style lang="scss">
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  color: #3c3c3c;
}
@import "uview-plus/index.scss";
@import "./uni.scss";

@font-face {
  font-family: "my-font";
  src: url("@/static/font/AlimamaAgileVF-Thin.ttf");
}

* {
  font-size: 14px;
}

body {
  font-family: "my-font", sans-serif;
}

#app {
  width: 750rpx;
  height: 100vh;
  overflow: hidden;
}
</style>
